<%@page import="java.io.BufferedWriter"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="db.*"%>
<%@ page import="java.sql.*" %>
<%@ page import="at.jku.ce.georg.*" %>
<%@ page import="java.util.*" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Aktuelle Bestellungen</title>
</head>
	<body>
	<a href="index.jsp">index.jsp</a><br>
	
	<form  action="aktuelleBestellungen.jsp" method="get">
		URL: <input type="text" id="url" name="url" value="http://140.78.73.87:8090/WebServices/services/BOMServiceImplPort?wsdl"  /> <br />
		
		Lieferant wählen: 	
		<select name="action" id="action" >
			<%
				DataAccess mgr = DataAccess.getDataAccessMgr(); 
				ResultSet rs = mgr.getAllSuppliers();
			
				 while(rs.next()) {
					 out.println("<option value="+rs.getString(1)+">"+rs.getString(1)+"</option><br/>");
				 }
				rs.close();
			%>
		</select>
		
		<button type="submit">OK</button>
	</form>
	<%
	GUI service = (GUI)application.getAttribute("myservice");
	if(service == null) {
		service = GUI.getInstance();
		application.setAttribute("myservice", service);
	}
	
	String url = request.getParameter("url");
	if(url !=null && !url.isEmpty())
		service.connectTo(url);
	
	String action = request.getParameter("action");
	if(action!=null) {		
		rs = mgr.getSupplierOrders(action);
		List<String> list = mgr.printData(rs);
		if (list!=null)
			for(String txt : list)	
				out.print(txt);			
		}	
	
	service.getLog();
	%>
	</body>
</html>